﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ProjectRoughWork
{
    class ShotgunNerf : BaseActor
    {
        public ShotgunNerf(Vector3 initPos, int initShooterID) : base(initPos)
        {
            //Initialize shotgun nerf parameters

            maxAccel = 3;
            maxVel = 3;

            damage = 500;
            shooterID = initShooterID;

            InitVertices();

            mType = "ShotgunNerf";

            //Set up origin and bounding sphere

            mOrigin = new Vector3(mPos.X + size / 2, mPos.Y + size / 2, mPos.Z + size / 2);
            bSphere = new BoundingSphere(mOrigin, size / 2);
        }

        //Sets up stuff for placeholder model

        public void InitVertices()
        {
            size = 5;

            vertices = new VertexPositionColorTexture[8];

            vertices[0].Position = new Vector3(0, 0, 0);
            vertices[0].Color = Color.Red;

            vertices[1].Position = new Vector3(0, size, 0);
            vertices[1].Color = Color.Red;

            vertices[2].Position = new Vector3(size, size, 0);
            vertices[2].Color = Color.Red;

            vertices[3].Position = new Vector3(size, 0, 0);
            vertices[3].Color = Color.Red;

            vertices[4].Position = new Vector3(0, 0, size);
            vertices[4].Color = Color.Red;

            vertices[5].Position = new Vector3(0, size, size);
            vertices[5].Color = Color.Red;

            vertices[6].Position = new Vector3(size, size, size);
            vertices[6].Color = Color.Red;

            vertices[7].Position = new Vector3(size, 0, size);
            vertices[7].Color = Color.Red;

            short[] temp = {
                               0,1,2,       //Front
                               2,3,0,
                               4,5,1,       //Left
                               1,0,4,
                               4,5,6,       //Back
                               6,7,4,
                               3,2,6,       //Right
                               6,7,3,
                               0,4,7,       //Bottom
                               7,3,0,
                               1,5,6,       //Top
                               6,2,1
                           };

            indices = temp;
        }

        /// <summary>
        /// Property for the damage dealt
        /// </summary>

        public int Damage
        {
            get { return damage; }
        }

        /// <summary>
        /// Property for the ID of the shooter
        /// </summary>

        public int ShooterID
        {
            get { return shooterID; }
        }

        public override void VRender()
        {
            //Special Nerf Rendering goes here

            GraphicsDevice device = Game1.GetGraphicsDevice();

            Effect customEffect = Game1.GetCustomEffect();
            customEffect.Parameters["World"].SetValue(Matrix.CreateTranslation(mPos));

            foreach (EffectPass pass in customEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                device.DrawUserIndexedPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, indices.Length / 3);
            }

            base.VRender();
        }

        //Data Member

        VertexPositionColorTexture[] vertices;
        short[] indices;
        int size;

        int damage;             //Damage to be dealt
        int shooterID;          //ID of the shooter
    }
}
